(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = {}.hasOwnProperty,
    __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

  this.FriendsIsAcceptedListingView = (function(_super) {

    __extends(FriendsIsAcceptedListingView, _super);

    function FriendsIsAcceptedListingView() {
      this.afterLoad = __bind(this.afterLoad, this);
      return FriendsIsAcceptedListingView.__super__.constructor.apply(this, arguments);
    }

    FriendsIsAcceptedListingView.prototype.initialize = function() {
      FriendsIsAcceptedListingView.__super__.initialize.apply(this, arguments);
      this.setElement("#main");
      this.model.bind("change", this.render);
      return this.model.fetch();
    };

    FriendsIsAcceptedListingView.prototype.render = function() {
      var _this = this;
      return this.GetTemplate(SiteMap.Friends.FriendsIsAcceptedListingEmptyTemplate, function(template) {
        $(_this.el).html(template(_this.model.toJSON()));
        _this.startLoading();
        _this.renewScrolling();
      });
    };

    FriendsIsAcceptedListingView.prototype.events = {
      "click a.accept": "accept",
      "click a.reject": "reject"
    };

    FriendsIsAcceptedListingView.prototype.accept = function(event) {
      var _this = this;
      event.preventDefault();
      return $.ajax({
        type: "POST",
        url: SiteMap.Friends.AddToFriends + "?friendLogin=" + $(event.currentTarget).data("friend-login"),
        success: function(response) {
          return _this.model.fetch();
        }
      });
    };

    FriendsIsAcceptedListingView.prototype.reject = function(event) {
      var _this = this;
      event.preventDefault();
      return $.ajax({
        type: "POST",
        url: SiteMap.Friends.DeleteFromFriend + "?userId=" + this.model.get("UserId") + "&friendId=" + $(event.currentTarget).data("friend-id"),
        success: function(response) {
          return _this.model.fetch();
        }
      });
    };

    FriendsIsAcceptedListingView.prototype.afterLoad = function(data) {
      var _this = this;
      return this.GetTemplate(SiteMap.Friends.FriendsIsAcceptedListingTemplate, function(compiledTemplate) {
        return $(_this.el).find("ul.friends-listing-accepted").append(compiledTemplate(data));
      });
    };

    return FriendsIsAcceptedListingView;

  })(ScrollPagingView);

}).call(this);
